home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10696 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: in1.uu.net!interaccess!usenet
  2. From: brianmcg@interaccess.com (Brian V. McGroarty)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Q about the float point format......
  5. Date: 19 Mar 1996 14:47:50 GMT
  6. Organization: Internet Squire
  7. Message-ID: <4imhem$12b@nntp.interaccess.com>
  8. References: <s3032089.15.314E68DD@sparc13.ncu.edu.tw>
  9. Reply-To: brianmcg@interaccess.com
  10. NNTP-Posting-Host: d46-isdn.nhe.interaccess.com
  11. X-Newsreader: Internet Squire 1.20
  12.  
  13. In your printf statement, add a decimal point and a number between the %
  14. and the f.
  15.  
  16. For example:
  17.  
  18. printf("%.4f", 1234.56789"); /* prints "1234.5678" */
  19. printf("%.2f", 1234.56789"); /* prints "1234.57" - last digit rounded upward */
  20. printf("%.9f", 1234.56789"); /* prints "1234.567890000" - zero is filled to
  21. right */
  22.  
  23.  
  24.  
  25. Alexander PeaceLand wrote:
  26. >   Could I dynamicly set the digits after the float POINT?
  27.  
  28. >   In other word... I use printf to print the float point number
  29. >                    like 123.456789 but in the other time i only 
  30. >                    want to print 123.456 or 123.4 
  31. >                    How shall I do? Thanks! :)
  32.  
  33. >                   (Forgive me so poor in writing English!)
  34.  
  35.  
  36.  
  37. ---
  38. Brian Valters McGroarty -- brianmcg@bix.com
  39. phone/fax (847) 439-7714
  40.  
  41.  
  42.  
  43.  
  44.